package com.example.springboot.controller;

import com.example.springboot.entity.Role;
import com.example.springboot.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/roles")
public class RoleController {
    @Autowired
    private RoleMapper roleMapper;

    //用get请求查询数据库信息
    @GetMapping
    public List<Role> findAll(){
        return roleMapper.findAll();//查询所有数据
    }

    @GetMapping("/{id}")
    public String findById(@PathVariable Integer id){
        return roleMapper.findById(id);
    }
}
